<%@ page import="com.apexedu.biz.entity.TServiceCode" %>
<%@ page import="com.apexedu.biz.entity.TServiceCodesort" %>
<%@ page import="com.apexedu.framework.util.SysPropertiesUtil" %>
<%@ page import="com.apexedu.identity.IdConstants" %>
<%@ page import="com.apexedu.identity.entity.LoginUserVO" %>
<%@ page import="com.apexedu.identity.security.CasLoginUtil" %>
<%@ page import="com.apexedu.util.StringUtil" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Random" %>
<jsp:useBean id="showBean" scope="application" class="com.apexedu.biz.IndexPageQuery" />
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    request.setAttribute("basePath", basePath);
    SimpleDateFormat sdf_time = new SimpleDateFormat("yyyy/MM/dd");
    Random rand =new Random();
    LoginUserVO tsysUser = (LoginUserVO) session.getAttribute(IdConstants.SESSION_USER);
    String userid="";
    String username="";
    if (tsysUser!=null){
        userid=tsysUser.getUserloginid();
        username=tsysUser.getUsername();
    }
    String serviceids=request.getParameter("serviceids")!=null?request.getParameter("serviceids"):"";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>山东大学网上服务大厅</title>
    <script src="${basePath}/resources/js/shd/jquery.js"></script>
    <script src="${basePath}/resources/jquery/jquery.raty.min.js"></script>
    <script src="${basePath}/resources/js/shd/raty.js"></script>
    <link href="${basePath}/resources/css/shd/se-center.css" rel="stylesheet" type="text/css" />
    <script src="${basePath}/component/layer/layer.js" type="text/javascript"></script>
    <script type="application/javascript">
        var conditions='';
        var userid='<%=userid%>';
        $(function() {
            var serviceids='<%=serviceids%>';
            if (serviceids!=''){
                var serviceid=serviceids.split(",");
                for (var i=0;i<serviceid.length;i++){
                    var textTypeIndex = $("#s__"+serviceid[i]).parents("div").index();//获取a当前的dl索引值
                    $(".tab-lv1:eq(" + textTypeIndex + ")").find("li").removeClass("active");
                    $("#s__"+serviceid[i]).addClass("active");
                }
            }
            $(".condition-box").height($("#conditionLabels").height()+90);
            $(".tab-lv1 li").click(function(){
                conditions='';
                var textTypeIndex = $(this).parents("div").index();//获取a当前的dl索引值
                var text = $(this).text();
                $(".tab-lv1:eq(" + textTypeIndex + ")").find("li").removeClass("active");
                $(this).addClass("active");
                search_service();
            })
            $("#condSearchBtn").on("click", function () {
                search_service();
            });
        });
        function search_service(){
            $("#conditionLabels .active").each(function(){
                var a = $(this).attr("data-label-id");
                if (a!=''&&a!=undefined&&a!='undefined'){
                    conditions+=a+",";
                }
            });
            var url="${basePath}/ajaxSearch";
            var path="${basePath}";
            var gjz=$("#gjz").val();
            $.post(url, {
                conditions:conditions,
                gjz:gjz,
                path: path
            },function (data) {
                $(".resulted").html(data);
                raty();
            });
        }
        function add_service(menuid){
            if (userid==''||userid==null){
                layer.msg("请您先登录！");
                return false;
            }
            if (menuid==''||menuid==null){
                layer.msg("请您选择收藏的服务！");
                return false;
            }
            var url="${basePath}/s/uc/shd/se/s/"+menuid+"/dyfw";
            $.post(url,function (data) {
                if (data=='ok') {
                    layer.msg("服务已收藏到个人中心--我订阅的服务！");
                }else if(data=="unauthorized"){
                    layer.msg("您未获得服务授权！");
                }else{
                    layer.msg("服务收藏失败！");
                }
            });
        }
        var basePath = '${basePath}';
        function execLogout() {
            <%
            if( CasLoginUtil.isSsoEnabled() ){
              // 通知业务系统liveBos登出。
              // 这里的地址是根据项目现场业务系统地址在门户管理后台的系统参数维护里修改。参数名用“livebos.urls”
                String liveBosUrl = SysPropertiesUtil.get("livebos.urls");
                if(StringUtil.isNotBlank(liveBosUrl)){
                    String[] liveBosUrls = liveBosUrl.split(",");
                    for(String url : liveBosUrls){
                        out.println("$(\"<iframe src='"+url+"/logout.do' height='0' frameborder='0'/>\").appendTo(\"body\");");
                    }
                }
            }
            %>
            $.get("${basePath}/identity/ajaxlogin.action?act=logout", {q: (new Date()).getTime()}, function (data) {
                data = eval("(" + data + ")");
                if (data.msg == 'success') {
                    <%
                if( CasLoginUtil.isSsoEnabled() ){
                %>
                    window.location.href = '<%=CasLoginUtil.getCasServerLogoutUrl()%>?t=' + Math.round(new Date / 1000);
                    <%
                    }else{
                    %>
                    window.location.href = '<%=request.getContextPath() %>?t=' + Math.round(new Date / 1000);
                    <%
                    }
                    %>
                } else {
                    alert(data.msg);
                }
            });

        }
    </script>
</head>
<body>
<body>
<!--header开始-->
<div id="hint" class="hint" style="display: none;"></div>
<div class="header-wide bgRed">
    <div class="fontYH " style="width: 1136px; margin: 0 auto">
        <div style="height: 56px; width: 418px; float: left; background-image: url('${basePath}/resources/images/shd/index/logol.png')">
        </div>
        <div class="topMenu">
            <ul>
                <li><a href="${basePath}">首页</a></li>
                <li><a class="home" href="${basePath}/s/shd/fwdh">服务导航</a></li>
                <%
                    if(StringUtil.isBlank(userid)){
                %>
                <li><a href="${basePath}/index_login.jsp">用户登录</a></li>
                <%
                    }else{
                %>
                <li><a href="${basePath}/s/uc/shd/ph">个人中心</a></li>
                <li><a href="#" onclick="execLogout()">注销</a></li>
                <%
                    }
                %>

            </ul>
        </div>
    </div>
</div>
<!--header结束-->
<!--右侧边滚动栏内容开始-->
<aside id="rightSide" class="panel-lv2">
</aside>
<!--右侧边栏滚动内容结束-->
<!--检索开始-->
<div class="yard-1136 ">
    <div id="condition-box" class="condition-box panel">
        <div class="title">
            服务导航 <span class="eg">Service Centre</span>
        </div>
        <div class="line-bottom">
            <label>
                关键字：</label>
            <div class="cond-search-box">
                <input id="gjz" maxlength="38" style="height: 28px;width:275px;" class="searching" type="text" placeholder="搜索服务" name="gjz" value="${gjz}">
            </div>
            <button id="condSearchBtn">搜索</button>
        </div>
        <div id="conditionLabels">
        <%
        List<TServiceCodesort> tservicecodesortList = showBean.getTservicecodesortList();
        if(tservicecodesortList.size()>0){
            for (int i=0;i<tservicecodesortList.size();i++){
                TServiceCodesort tserviceCodesort =tservicecodesortList.get(i);
                List<TServiceCode> tservicecodeList =tserviceCodesort.getTservicecodeList();
                if(tservicecodeList.size()>0){
        %>
            <div class="line-bottom">
                <label data-service-id="<%=i%>">
                    <%=tserviceCodesort.getLbmc()%>：</label>
                <ul class="tab-lv1">
                    <li class="active" data-label-id="">全部</li>
                    <%
                       for (int j=0;j<tservicecodeList.size();j++){
                             TServiceCode tserviceCode =tservicecodeList.get(j);
                    %>
                       <li class="" data-label-id="c__<%=tserviceCode.getZdbm()%>" id="s__<%=tserviceCode.getZdbm()%>"><%=tserviceCode.getZdmc()%></li>
                    <%
                       }
                    %>
                </ul>
            </div>
       <%
                   }
            }
        }
        %>
            <div class="line-bottom">
                <label data-service-id="50">
                    排序类别：</label>
                <ul class="tab-lv1 primary">
                    <li class="active" data-label-id="order__mc">服务名称</li>
                    <li class="" data-label-id="order__djs">热门程度</li>
                    <li class="" data-label-id="order__cjrq">发布时间</li>
                </ul>
            </div>
            <div class="line-bottom">
                <label data-service-id="60">排序方式：</label>
                <ul class="tab-lv1 primary">
                    <li class="active" data-label-id="sorting__asc" id="asc">升序</li>
                    <li class="" data-label-id="sorting__desc" id="desc">降序</li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!--检索结束-->
<!--检索结果开始---------------------------------------------------------------------------------------------------------------------------------------------------------->
<div class="yard-1136-bg" >
    <div class="resulted" >
        <ul class="ly-clearFix">
            <c:forEach var="menu" items="${resultList }">
            <li >
                <div class="image" onclick="window.open('${basePath}/s/shd/fwdh/details/${menu.menuid}');">
                    <i class=""></i>
                    <img src="${basePath}/resources/images/shd/index/icon/<%=rand.nextInt(11)+1%>.png">
                </div>
                <div class="information" onclick="window.open('${basePath}/s/shd/fwdh/details/${menu.menuid}');">
                    <div style="overflow: hidden">
                        <div class="title fontYH tl" title="${menu.menuname}">${menu.menuname}</div>
                        <i class=""></i>
                    </div>
                    <div class="classify fontYH tl" title="${menu.fwtype}">${menu.fwtype}</div>
                </div>
                <div class="informationxx">
                    <div class="alines">
                        <label>办理单位：</label><span title="${menu.unit}">${menu.unit}</span>
                    </div>
                    <div class="alines">
                        <label>办理时间：</label><span title="${menu.workingtime}">${menu.workingtime}</span>
                    </div>
                    <div class="alines">
                        <label>办理地点：</label><span title="${menu.workingplace}">${menu.workingplace}</span>
                    </div>
                    <div class="alines">
                        <label>联系方式：</label><span title="${menu.contact}">${menu.contact}</span>
                    </div>
                    <div class="alines">
                        <label style="margin-top: -2px;">满意度：</label>
                        <span class="star" data-score="${menu.score}" data-readOnly="true" style="height: 16px;line-height: 16px;text-align: center"></span>
                    </div>
                    <div class="collection">
                        <div onclick="add_service('${menu.menuid}')">
                            <img src="${basePath}/resources/images/shd/index/star.png" width="23" height="40" alt="" /><span>订 阅</span>
                        </div>
                    </div>
                </div>
            </li>
            </c:forEach>
        </ul>
    </div>
</div>
<!--检索结果结束---------------------------------------------------------------------------------------------------------------------------------------------------------->
<!--快捷通道开始-->
<div class="service">
    <div class="channel ">
        <div class="channel-q">
            <ul>
                <li><a href="http://portal.sdu.edu.cn/" target="_black"><img src="${basePath}/resources/images/shd/index/icon/k1.png" alt="办公系统" width="92" height="92" /></a></li>
                <li><a href="http://www.oa.sdu.edu.cn/" target="_black"><img src="${basePath}/resources/images/shd/index/icon/k2.png" alt="OA系统" width="92" height="92" /></a></li>
                <li><a href="http://www.lib.sdu.edu.cn/portal/tpl/home/index" target="_black"><img src="${basePath}/resources/images/shd/index/icon/k3.png" alt="图书馆" width="92" height="92" /></a></li>
                <li><a href="http://www.culture.sdu.edu.cn/" target="_black"><img src="${basePath}/resources/images/shd/index/icon/k4.png" alt="山大文化" width="92" height="92" /></a></li>
                <li><a href="http://www.rsc.sdu.edu.cn/2010new2/zp.php" target="_black"><img src="${basePath}/resources/images/shd/index/icon/k5.png" alt="人才招聘" width="92" height="92" /></a></li>
                <li><a href="http://www.view.sdu.edu.cn/" target="_black"><img src="${basePath}/resources/images/shd/index/icon/k6.png" alt="山大新闻" width="92" height="92" /></a></li>
            </ul>
        </div>
    </div>
</div>
<!--快捷通道结束-->
<!--footer开始-->
<%@include file="./public_foot.jsp"%>
<!--footer结束-->
</body>
</html>
